home *** CD-ROM | disk | FTP | other *** search
- #include<exec/libraries.h>
- #include<intuition/intuition.h>
- #include<utility/tagitem.h>
- #include<graphics/text.h>
-
- #include<string.h>
-
- #include<clib/exec_protos.h>
- #include<clib/graphics_protos.h>
- #include<clib/intuition_protos.h>
-
- struct Library* GfxBase;
- struct Library* IntuitionBase;
-
- /* Need to give a prototype for our message handling function */
- void handleIDCMP(struct Window*);
-
- void main()
- {
- /* Open libraries... */
- if(GfxBase = OpenLibrary("graphics.library",36))
- {
- if(IntuitionBase = OpenLibrary("intuition.library",36))
- {
- /* Open our window */
- struct Window* win;
- if(win = OpenWindowTags(NULL,
- WA_Left, 20,
- WA_Top, 20,
- WA_Width, 200,
- WA_Height, 100,
- WA_Flags, WFLG_CLOSEGADGET | WFLG_DRAGBAR,
- WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_MOUSEBUTTONS,
- TAG_DONE, 0))
- {
- /* If window opened, handle its IDCMP messages */
- handleIDCMP(win);
- CloseWindow(win);
- }
- CloseLibrary(IntuitionBase);
- }
- CloseLibrary(GfxBase);
- }
- }
-
- /* Our message handling code */
- void handleIDCMP(struct Window* win)
- {
- char* text = "Hello World!";
- int going = TRUE;
- SetAPen(win->RPort, 1);
- /* Loop, waiting for messages, until the close gadget clicked */
- while(going)
- {
- struct IntuiMessage* intuimsg;
- /* Wait for messages to arrive */
- WaitPort(win->UserPort);
- /* Messages have arrived: loop through all of them */
- while(intuimsg = (struct IntuiMessage*)GetMsg(win->UserPort))
- {
- /* Act on this message... */
- switch(intuimsg->Class)
- {
- case IDCMP_CLOSEWINDOW:
- going = FALSE;
- break;
- case IDCMP_MOUSEBUTTONS:
- Move(win->RPort, intuimsg->MouseX, intuimsg->MouseY);
- Text(win->RPort, text, strlen(text));
- break;
- }
- /* Reply when finished with message */
- ReplyMsg((struct Message*)intuimsg);
- }
- }
- }
-